package com.frame.work.frame.deal.device0faa;

import com.alibaba.fastjson.JSONObject;
import com.frame.work.common.util.JsonToMqtt;
import com.frame.work.frame.deal.base.BaseFrame;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 静音窗帘0FAA0E02
 */
@Data
public class JingYinChuangLian_0FAA0E02 extends BaseFrame {

    //private String switchState;
    private String spreadingType;
    public JingYinChuangLian_0FAA0E02(String gatewayMac, String data) {

        //将基础数据进行处理
        super(gatewayMac, data);
        //处理此设备特有的数据
        //this.setSwitchState("");
        String mode = StringUtils.substring(data, 58, 60);
        if (mode.startsWith("8")){
            return;
        }
        this.setSpreadingType(StringUtils.substring(data, 38, 40));
        //将actions信息放入json对象中
        String position = StringUtils.substring(data, data.length()-6,data.length()-4);

        Map<String, Object> actions = new HashMap();
        //actions.put("position",Integer.valueOf(position,16));
        actions.put("position",position);
        this.setActions(actions);

        //处理好的json对象
        String json = JSONObject.toJSONString(this);
        //将数据发送到mqtt队列中
        JsonToMqtt.sendMQTT(gatewayMac, json);

    }
}
